package com.sdd.rpi_mobile.eventRss;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/** Small utility class to handle downloading files */
public class fileDownloader{
	
	/**
	 * Creates an input stream for a file
	 * @param fileUrl the URL of the file to be downloaded
	 * @return Stream for file
	 * @throws IOException
	 */
	public static InputStream downloadFile(String fileUrl) throws IOException {
		URL url = new URL(fileUrl);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setReadTimeout(10000);
        conn.setConnectTimeout(15000);
        conn.setRequestMethod("GET");
        conn.setDoInput(true);
        conn.connect();
        InputStream reader = conn.getInputStream();
        return reader;
	}
}
